package javaAPI.String.String2;

public class String2 {
    public static void main(String[] args) {
        int []arr={1,2,3};
        String str=arrToString(arr);
        System.out.println(str);
    }
    public static String arrToString(int[]arr){
        String result="[";
        if(arr==null){
            return"";
        } else if (arr.length==0) {
            return "[]";
        }else {
            for (int i = 0; i < arr.length; i++) {
                if (i == arr.length - 1) {
                    result = result + arr[i];
                } else {
                    result = result + arr[i] + ",";
                }
            }
            result=result+"]";
            return result;
        }
    }
}
